// 初始化高德地图的 key 和插件
window.VueAMap.initAMapApiLoader({
  key: 'fa712dc98e48730eb2d9f27f15df19d6',
  plugin: ['Autocomplete', 'PlaceSearch', 'Scale', 'OverView', 'ToolBar', 'MapType', 'PolyEditor', 'AMap.CircleEditor'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
});
let amapManager = new VueAMap.AMapManager();

var nowDate=new Date();
//console.log(nowDate);

var comFilePath = './components' //组件框架路径
document.write("<scr" + "ipt src='" + comFilePath + "/amap_map_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/header_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/footer_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/site_banner_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/home/banner_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/home/advance_search_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/home/featured_properties_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/home/announcement_section_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/home/office_for_rent_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/home/why_choose_us_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/column_left_com.js'></scr" + "ipt>");

// document.write("<scr" + "ipt src='" + comFilePath + "/amap_map_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/home_column_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/about_column_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/goods/goods_column_detail_com.js'></scr" + "ipt>");
//document.write("<scr" + "ipt src='" + comFilePath + "/goods/goods_column_right_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/goods/goods_column_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/news/news_column_right_com.js'></scr" + "ipt>");
document.write("<scr" + "ipt src='" + comFilePath + "/news/news_column_com.js'></scr" + "ipt>");

document.write("<scr" + "ipt src='" + comFilePath + "/contact_column_com.js'></scr" + "ipt>");

// jquery 的ready() 与window.onload()的区别
// https://www.cnblogs.com/wsun/p/3916487.html

$(document).ready(function(){


// window.onload =function () {

//var section = document.getElementsByTagName('section');

Vue.component('headerCom',headerCom);
Vue.component('footerCom',footerCom);
//Vue.component('columnLeftCom',columnLeftCom);


//Vue.component('homeColumnCom',homeColumnCom);
//Vue.component('newsColumnCom',newsColumnCom);

Vue.use(VueRouter);
const router = new VueRouter({
//mode: 'history', //切换路径模式，变成history模式  消除 #
routes: [
  { path: '/home', component: homeColumnCom },
  { path: '/about', component: aboutColumnCom },
  { path: '/goods', component: goodsColumnCom,
      children:[
        {
          path:'/goods/:types',
          component:goodsColumnCom
        }
      ]
  },
  { path: '/goodsDetail/:id', component:goodsColumnDetailCom },
  { path: '/news', component: newsColumnCom,
      children:[
        {
          path:'/news/:type',
          component:goodsColumnCom
        }
      ]
  },
  { path: '/contact', component: contactColumnCom },
  { path: "/",redirect: "/home" },
  { path: "*",redirect: "/home" }  //404重定向
]
});


//axios.defaults.baseURL = 'http://www.cmsya.com';
//axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';



var vm = new Vue({
    el:'#box',
    router,
    data:{
      sendData:{
        house:[],
        news:[],
        msg:'Main组件数据'
      }

    },
    components:{
      //homeColumnCom,
      //goodsColumnDetailCom,
      contactColumnCom,
    },
    mounted: function() {
        this.$nextTick(function() {//this.TouchSlide();
          //this.browserTips();
          this.getHouseList();
          //this.zoomShow();

        });
    },
    methods: {

      browserTips:function(){
        var browserTips = document.getElementsByTagName('header')[0];
        var alertWarning = document.getElementsByClassName('alert-warning')[0];
        if (!browserTips) {
          alert('浏览需要升级！')
        } else {
          // console.log('已经兼容！ https://cn.vuejs.org/v2/guide/#%E4%B8%8E%E8%87%AA%E5%AE%9A%E4%B9%89%E5%85%83%E7%B4%A0%E7%9A%84%E5%85%B3%E7%B3%BB');
          alertWarning.style.display = 'none';
        }        
      },
      getHouseList(){
          axios.get('./data/house.json')
          //axios.get('./netUrl.json')
          .then(function (res) {
            //console.log(res.data.result);
            this.sendData.house = res.data;
            localStorage.setItem('house',JSON.stringify(this.sendData.house));
          }.bind(this)).catch(
            function (err) {
              console.log(err);
            }
          )
      }, //getGoodsList end

      zoomShow(){
        $("a.zoom").on("click", function (e) {
            e.preventDefault();
        });
      }, //getNewsList end



    },
});





// }  // window.onload  end




}); // $(document).ready() end